<?php
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require '../com.swiss.mooh.dao.impl/CarouselDaoImpl.php';
require '../com.swiss.mooh.service/CarouselServiceImpl.php';
require '../com.swiss.mooh.model/Carousel.php';

$dispatcher = new CarouselDaoImpl();
$caService = new CarouselServiceImpl($dispatcher);

if ($_POST['type'] == "LEFT") {
    $resultList = $caService->getAllLeftCarousel();
    for ($i = 0; $i < $resultList->Size(); $i++) {
        $resultVO = $resultList->GetObj($i);
        ?>
        <a href="#" class="list-group-item">            
            <span class="badge" onclick="deleteCarousel('<?= $resultVO->getCaID(); ?>')"><i class="fa fa-trash"></i></span>
            <span><i class="fa fa-fw fa-calendar"></i> <?= $resultVO->getCaName(); ?></span>
        </a>
        <?php
    }
}
if ($_POST['type'] == "CENTER") {
    $resultList = $caService->getAllCenterCarousel();
    for ($i = 0; $i < $resultList->Size(); $i++) {
        $resultVO = $resultList->GetObj($i);
        ?>
        <a href="#" class="list-group-item">            
            <span class="badge" onclick="deleteCarousel('<?= $resultVO->getCaID(); ?>')"><i class="fa fa-trash"></i></span>
            <span><i class="fa fa-fw fa-calendar"></i> <?= $resultVO->getCaName(); ?></span>
        </a>
        <?php
    }
}
if ($_POST['type'] == "RIGHT") {
    $resultList = $caService->getAllRightCarousel();
    for ($i = 0; $i < $resultList->Size(); $i++) {
        $resultVO = $resultList->GetObj($i);
        ?>
        <a href="#" class="list-group-item">            
            <span class="badge" onclick="deleteCarousel('<?= $resultVO->getCaID(); ?>')"><i class="fa fa-trash"></i></span>
            <span><i class="fa fa-fw fa-calendar"></i> <?= $resultVO->getCaName(); ?></span>
        </a>
        <?php
    }
}
if ($_POST['type'] == "BUTTOM") {
    $resultList = $caService->getAllButtomCarousel();
    for ($i = 0; $i < $resultList->Size(); $i++) {
        $resultVO = $resultList->GetObj($i);
        ?>
        <a href="#" class="list-group-item">            
            <span class="badge" onclick="deleteCarousel('<?= $resultVO->getCaID(); ?>')"><i class="fa fa-trash"></i></span>
            <span><i class="fa fa-fw fa-calendar"></i> <?= $resultVO->getCaName(); ?></span>
        </a>
        <?php
    }
}
if ($_POST['type'] == "OTHER") {
    $resultList = $caService->getAnotherCAByID($_POST['descID']);
    for ($i = 0; $i < $resultList->Size(); $i++) {
        $resultVO = $resultList->GetObj($i);
        ?>
        <a href="#" class="list-group-item">            
            <span class="badge" onclick="deleteCarousel('<?= $resultVO->getCaID(); ?>')"><i class="fa fa-trash"></i></span>
            <span><i class="fa fa-fw fa-calendar"></i> <?= $resultVO->getCaName(); ?></span>
        </a>
        <?php
    }
}